
"""知识页面基类"""
from pages.base_page import BasePage
from selenium.webdriver.common.by import By
class KnowledgeHomePage(BasePage):
    url = 'crm/index.php?m=knowledge'
     #定位器
     #添加知识
    add_knowledge_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div:nth-child(2) > div > div.pull-right > a')
    # 断言添加成功信息
    knowledge_add_success_locator = (By.CSS_SELECTOR, 'body > div.container > div.alert.alert-success')
    #点击全部
    knowledge_all_locator=(By.CSS_SELECTOR,'body > div.container > div.row > div.span2.knowledgecate > ul > li:nth-child(2) > a')
    # 选择第一条知识
    knowledge_first_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr > td:nth-child(1) > input')
    # 点击删除
    knowledge_delete_locator = (By.CSS_SELECTOR, "#delete")

    #点击添加知识
    def click_add_knowledge(self):
        self.driver.find_element(*self.add_knowledge_locator).click()

    # 断言
    def message_add_knowledge(self):
        message_knowledge = self.driver.find_element(*self.knowledge_add_success_locator).text
        return message_knowledge
    #点击全部
    def click_all_knowledge(self):
        self.driver.find_element(*self.knowledge_all_locator).click()
    #选择第一条知识
    def click_first_knowledeg(self):
        self.driver.find_element(*self.knowledge_first_locator).click()
    # 点击删除
    def click_knowledeg_delete(self):
        self.driver.find_element(*self.knowledge_delete_locator).click()


